package com.dhsc.service.impl.zxjk;

import com.dhsc.domain.jkzx.zxjk.YgkzzqxjkVo;
import com.dhsc.domain.yypt.LayuiTableVo;
import com.dhsc.domain.yypt.ResponseObject;
import com.dhsc.exception.MyException;
import com.dhsc.local.dao.zxjk.IYgkzzqxjkDao;
import com.dhsc.service.zxjk.IYgkzzqxjkService;
import com.github.pagehelper.PageInfo;
import com.github.pagehelper.page.PageMethod;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author 员工可转债权限监控
 * @date 2024/11/12 10:22
 */
@Service
@Slf4j
public class YgkzzqxjkServiceImpl implements IYgkzzqxjkService {

    @Autowired
    private IYgkzzqxjkDao ygzqxjkDao;
    @Override
    public LayuiTableVo queryYgkzzqxjkinfo(YgkzzqxjkVo y) {
        LayuiTableVo obj = new LayuiTableVo();
        try{
            PageMethod.startPage(y.getPage(), y.getLimit());
            List<YgkzzqxjkVo> list = ygzqxjkDao.queryYgkzzqxjkinfo(y);
            PageInfo<YgkzzqxjkVo> pageInfo = new PageInfo<>(list);
            obj.setData(list);
            obj.setMsg("");
            obj.setCount(pageInfo.getTotal());
            obj.setCode(0);
        }catch(Exception e){
            log.error("员工可转债权限监控出错", e);
            throw new MyException("员工可转债权限监控出错",e);
        }
        return obj;
    }

    @Override
    public ResponseObject queryQszd(YgkzzqxjkVo y) {
        ResponseObject obj = new ResponseObject();
        try {
            List<YgkzzqxjkVo> list = ygzqxjkDao.queryQszd(y);
            obj.setStatus(200);
            obj.setData(list);
        }catch (Exception e){
            log.error("查询qs.txtdm字典出错",e);
            throw new MyException("查询qs.txtdm字典出错",e);
        }
        return obj;
    }

    @Override
    public ResponseObject queryZhzd(YgkzzqxjkVo y) {
        ResponseObject obj = new ResponseObject();
        try {
            List<YgkzzqxjkVo> list = ygzqxjkDao.queryZhzd(y);
            obj.setStatus(200);
            obj.setData(list);
        }catch (Exception e){
            log.error("查询zh.txtdm字典出错",e);
            throw new MyException("查询zh.txtdm字典出错",e);
        }
        return obj;
    }
}
